home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / AIncludes / AdminMessagePort.a < prev    next >
Text File  |  1996-05-01  |  3KB  |  122 lines

  1. ;
  2. ;    File:        AdminMessagePort.a
  3. ;
  4. ;    Contains:    xxx put contents here xxx
  5. ;
  6. ;    Version:    Technology:    xxx put the technology version here xxx
  7. ;                Release:    Universal Interfaces 3.0d3 on Copland DR1
  8. ;
  9. ;    Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10. ;
  11. ;    Bugs?:        If you find a problem with this file, send the file and version
  12. ;                information (from above) and the problem description to:
  13. ;
  14. ;                    Internet:    apple.bugs@applelink.apple.com
  15. ;                    AppleLink:    APPLE.BUGS
  16. ;
  17. ;
  18.     IF &TYPE('__ADMINMESSAGEPORT__') = 'UNDEFINED' THEN
  19. __ADMINMESSAGEPORT__ SET 1
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24.     IF FOR_SYSTEM8_PREEMPTIVE THEN
  25. ;
  26. ;//------------------------------------------------------------------------------------
  27. ;
  28. ;    The I/O system reserves one bit of the Kernel message system's type mask to use
  29. ;    for administration messages. Different services within the I/O system use this
  30. ;    single message type. The routine and constants described in this file are used
  31. ;    by clients of these administration services to distinguish between the different
  32. ;    types.
  33. ;    
  34. ;    It is intended that clients of I/O administration services use a single Kernel 
  35. ;    message port (PortID) for all messages: administration and data. Clients can
  36. ;    create multiple message objects (ObjectID) for the same port and pass a different
  37. ;    object to each administration service and use another for data handling.
  38. ;    
  39. ;    The client should use separate tasks to receive administration messages and data
  40. ;    messages. Use the message type parameter of ReceiveMessage as a bit-mask to specify
  41. ;    the type of message to receive in each task. The code below shows an example of an
  42. ;    administration task.
  43. ;    
  44. ;    AdministrationTask()
  45. ;    {
  46. ;        MessageControlBlock    mcb;
  47. ;        union {
  48. ;            DevNMessage        devn;
  49. ;            PMMessage        pm;
  50. ;            Arbitration        arb;
  51. ;        } adminBuffer;
  52. ;        UInt32                messageType;
  53. ;
  54. ;        while (true) 
  55. ;        {
  56. ;            ReceiveMessageSync(adminPort, kAMPMessageTypeMask, &mcb, &adminBuffer, ...)
  57. ;            AMPGetMessageType(mcb->messageContents, &messageType);
  58. ;            
  59. ;            switch (messageType)
  60. ;            {
  61. ;                case kAMPDeviceNotificationMsg:
  62. ;                    {
  63. ;                        DevNMessage* devn = mcb.messageContents;
  64. ;                        switch (devn->subMessageType)
  65. ;                        {
  66. ;                            ...
  67. ;                        }
  68. ;                    }
  69. ;                    break;
  70. ;                case kAMPPowerManagementMsg:
  71. ;                    {
  72. ;                        PMMessage* pm = mcb.messageContents;
  73. ;                        switch (pm->type)
  74. ;                        {
  75. ;                            ...
  76. ;                        }
  77. ;                    }
  78. ;                    break;
  79. ;                case kAMPArbitrationServiceMsg:
  80. ;                    {
  81. ;                        Arbitration* arb = mcb.messageContents;
  82. ;                        switch (arb->type)
  83. ;                        {
  84. ;                            ...
  85. ;                        }
  86. ;                    }
  87. ;                    break;
  88. ;                default:
  89. ;                    break;
  90. ;            }
  91. ;        }
  92. ;    }
  93. ;
  94. ;//------------------------------------------------------------------------------------
  95. ;
  96. ;     Constants for use in ReceiveMessage.
  97.  
  98. kAMPMessageTypeMask                EQU        $08000000            ; highest bit not reserved by the kernel
  99. kNonKernelNonAMPMessageTypes    EQU        $07FFFFFF
  100. ;     Constants returned by AMPGetMessageType
  101.  
  102. kAMPDeviceNotificationMsg        EQU        1
  103. kAMPPowerManagementMsg            EQU        2
  104. kAMPArbitrationServiceMsg        EQU        3
  105. ;
  106. ;    AMPGetMessageType:
  107. ;
  108. ;    Given an I/O administration message this routine determines the type of 
  109. ;    message. If the type cannot be deteremined zero is returned and debugging 
  110. ;    builds throw an assertion.
  111. ;
  112. ;
  113. ; extern void AMPGetMessageType(void *messageContents, UInt32 *messageType)
  114. ;
  115.     IF GENERATINGCFM THEN
  116.         IMPORT_CFM_FUNCTION AMPGetMessageType
  117.     ENDIF
  118.  
  119.     ENDIF
  120.     ENDIF ; __ADMINMESSAGEPORT__ 
  121.  
  122.